/**
 * @author LKQ
 * @date 2022/1/8 17:25
 * @description 双指针
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.isSubsequence("axc", "ahbgdc"));
    }

    public boolean isSubsequence(String s, String t) {
        int n = s.length(), m = t.length();
        int p = 0, q = 0;
        while (p < n && q < m) {
            char temp = s.charAt(p);
            if (t.charAt(q) == temp) {
                p++;
            }
            q++;
        }
        return p == n;
    }
}
